<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="contextPath" value="${pageContext.servletContext.contextPath}"></c:set>
<script type="text/javascript">
	function deleteaccount() {
		test.submit();
	}
	function selectAll() {
		var checklist = document.getElementsByName("authorid");
		if (document.getElementById("authoridAll").checked) {
			for (var i = 0; i < checklist.length; i++) {
				checklist[i].checked = true;
			}
		} else {
			for (var j = 0; j < checklist.length; j++) {
				checklist[j].checked = false;
			}
		}
	}
</script>


<div class="table-responsive" style="width: 500px;">
	<c:if test="${authorlist.size() != 0}">
	<form id="test" action="${contextPath}/delauthor.htm" method="get">
		<table id="mytable" class="table table-hover"
			style="text-align: center">
			<tr>
				<td style="width: 100px;">选择框</td>
				<td style="width: 100px;">作者编号</td>
				<td style="width: 100px;">firstName</td>
				<td style="width: 100px;">lastName</td>
				<td style="width: 100px;">操作</td>
			<c:forEach var="item" varStatus="status" items="${authorlist}">
				<tr>
					<td><input type="checkbox" name="authorid"
						value="${item.authorID}" /></td>
					<td>${item.authorID}</td>
					<td>${item.firstName}</td>
					<td>${item.lastName}</td>
					<td> <a href="${contextPath}/delauthor.htm?id=${item.authorID}">删除</a></td>
				</tr>
			</c:forEach>

			<tr>
				<td><input type="checkbox" onclick="selectAll()" id="authoridAll" />全选</td>
				<td>
						<button type="submit" class="btn btn-success">删除选中项</button>
				</td>
			</tr>
		</table>
	</form>
	</c:if>
	<c:if test="${authorlist.size() == 0}">
		<h2 align="center" class="text-danger"><em>作者为空</em></h2>
	</c:if>
</div>
